import java.util.List;
import java.util.Objects;

public class JEP502 {
    void main() {
        IO.println("测试模式匹配基础类型！");
        var elements = List.of(1, "a", 1.25);
        for (Object element : elements) {
            matchTypeAndPrint(element);
        }
    }

    /**
     * 模式匹配
     */
    private void matchTypeAndPrint(Object element) {
        Objects.requireNonNull(element, "element is null");
        if (element instanceof int) {
            IO.println("元素是int类型，值是: " + element);
        } else if (element instanceof String) {
            IO.println("元素是String类型，值是：" + element);
        }  else if ( element instanceof double ) {
            IO.println("元素是double类型， 值是： " + element);
        }
    }
}
